// components/good/good.js
import util from '../../../utils/utils'
import {
  RedPackets
} from '../../../api/redpackets.js'
const redPackets = new RedPackets();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: true
    },
    prizeInfo: Object

  },

  /**
   * 组件的初始数据
   */
  data: {
    shareModel: {
      title: '',
      path: '',
      imageUrl: '',
      fromButton: ''
    }
  },
  lifetimes: {
    attached: function() {
      let self = this
      let {
        goods_id,
        goods_name,
        order_id
      } = this.data.prizeInfo;
      redPackets.getWinningThePrize({
        spu_id: goods_id,
      }).then((res) => {
        console.log(this.data.prizeInfo)
        let share = {
          imageUrl: res.img_url,
          title: '我已中奖请及时发货',
          path: '/pages/redpackets/winningPrize/winningPrize?id=' + order_id,
          type: 'prize'
        }
        self.setData({
          shareModel: share
        })
      })
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {},

});